import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';
export namespace PerFamilyOperationApi {
  /** 从事经营活动信息 */
  export interface FamilyOperation {
    id: number; // 主键ID
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    familyName: string; // 姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 证件号码
    workUnit: string; // 工作单位
    position: string; // 职务
    enterpriseName: string; // 企业名称
    operateAddress: string; // 经营地
    isRelatedBusiness: number; // 是否从事与教育相关的经营活动（1：是，0：否）
    hasEconomicRelation: number; // 是否与领导干部所在单位/系统直接发生经济关系（1：是，0：否）
    remark: string; // 备注
    status: number; // 状态（1：有效，0：无效）
  }
}

/** 查询从事经营活动分页 */
export function getFamilyOperationPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<PerFamilyOperationApi.FamilyOperation>>(
    '/per/family-operation/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询从事经营活动详情 */
export function getFamilyOperation(id: number) {
  return requestClient.get<PerFamilyOperationApi.FamilyOperation>(
    `/per/family-operation/get?id=${id}`,
  );
}

/** 新增从事经营活动 */
export function createFamilyOperation(
  data: PerFamilyOperationApi.FamilyOperation,
) {
  return requestClient.post('/per/family-operation/create', data);
}

/** 修改从事经营活动 */
export function updateFamilyOperation(
  data: PerFamilyOperationApi.FamilyOperation,
) {
  return requestClient.put('/per/family-operation/update', data);
}

/** 删除从事经营活动 */
export function deleteFamilyOperation(id: number) {
  return requestClient.delete(`/per/family-operation/delete?id=${id}`);
}

/** 批量删除从事经营活动 */
export function deleteFamilyOperationList(ids: number[]) {
  return requestClient.delete(
    `/per/family-operation/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出从事经营活动 */
export function exportFamilyOperation(params: any) {
  return requestClient.download('/per/family-operation/export-excel', {
    params,
  });
}
